﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Http;
using HttpController.Filters;
using System.Net.Http;
using System.Net;

namespace HttpController
{
    public class P2PController : ApiController
    {
        /// <summary>
        /// 根据客户端类型获得首页信息
        /// </summary>
        /// <param name="id">客户端类型1:IOS;2:Android</param>
        /// <returns></returns>
        [ApiExceptionFilter(ErrorMsg = "获取P2P信息失败")]
        public HttpResponseMessage Get(int? id)
        {
            HttpResponseMessage rs = Request.CreateResponse(HttpStatusCode.OK);

            if (id.HasValue)
            {
                rs.Content = new StringContent(@"{""code"":1,""msg"":"""
                + "ok" + @""",""time"":"""
                + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + @"""}", System.Text.Encoding.UTF8, "application/json");
            }
            else
            {
                throw new Exception("id is null");
            }

            return rs;
        }
    }
}